class GeozoneController {

    def index = {redirect(action: list, params: params)}

    // the delete, save and update actions only accept POST requests
    def allowedMethods = [delete: 'POST', save: 'POST', update: 'POST']

    def list = {
        if (!params.max) params.max = 10
        [geozoneList: Geozone.list(params)]
    }

    def show = {
        def geozone = Geozone.get(params.id)

        if (!geozone) {
            flash.message = "Geozone not found with id ${params.id}"
            redirect(action: list)
        }
        else {
            redirect(controller: "geozone" + geozone.zoneType, action: "show", id:geozone.id)
        }
    }

    /**
    def delete = {
        def geozone = Geozone.get( params.id )
        if(geozone) {
            geozone.delete()
            flash.message = "Geozone ${params.id} deleted"
            redirect(action:list)
        }
        else {
            flash.message = "Geozone not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def geozone = Geozone.get( params.id )

        if(!geozone) {
            flash.message = "Geozone not found with id ${params.id}"
            redirect(action:list)
        }
        else {
            return [ geozone : geozone ]
        }
    }

    def update = {
        def geozone = Geozone.get( params.id )
        if(geozone) {
            geozone.properties = params
            if(!geozone.hasErrors() && geozone.save()) {
                flash.message = "Geozone ${params.id} updated"
                redirect(action:show,id:geozone.id)
            }
            else {
                render(view:'edit',model:[geozone:geozone])
            }
        }
        else {
            flash.message = "Geozone not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def geozone = new Geozone()
        geozone.properties = params
        return ['geozone':geozone]
    }

    def save = {
        def geozone = new Geozone(params)
        if(!geozone.hasErrors() && geozone.save()) {
            flash.message = "Geozone ${geozone.id} created"
            redirect(action:show,id:geozone.id)
        }
        else {
            render(view:'create',model:[geozone:geozone])
        }
    }
    */
}